﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DTOQLDV;
using BUSQLDV;
namespace QLDV_DA
{
    public partial class frmXuLiTuDongDuLuLieuSai : DevExpress.XtraEditors.XtraForm
    {       
        public frmXuLiTuDongDuLuLieuSai()
        {
            InitializeComponent();
            _arrck = new bool[6];         
        }   
        public delegate void ThucHien(bool []arr);

        public delegate void BoQua();

        public ThucHien _thucHien;

        public BoQua _boQua;

        private void ChonTatCa(bool ch)
        {
            ckTuDongThemDiaDiem.Checked = ch;
            ckTuDongThemMoiDichVu.Checked = ch;
            ckTuDongThemMoiDuong.Checked = ch;
            ckTuDongThemMoiPhuong.Checked = ch;
            ckTuDongThemMoiQuanHuyen.Checked = ch;
            ckTuDongThemMoiTinhThanh.Checked = ch;
        }

        private bool[] _arrck;

        private bool XuLiChonLua()
        {          
            _arrck[0] = ckTuDongThemDiaDiem.Checked;
            _arrck[1] = ckTuDongThemMoiDichVu.Checked;
            _arrck[2] = ckTuDongThemMoiDuong.Checked;
            _arrck[3] = ckTuDongThemMoiPhuong.Checked;
            _arrck[4] = ckTuDongThemMoiQuanHuyen.Checked;
            _arrck[5] = ckTuDongThemMoiTinhThanh.Checked;
            foreach (bool ck in _arrck)
            {
                if (ck == true)
                {
                    return true;
                }
            }
            return false;
        }            

        private void frmXuLiTuDongDuLuLieuSai_Load(object sender, EventArgs e)
        {
            ckTuDongThemMoiTatCa.Checked = true;
        }

        private void cnThucHien_Click(object sender, EventArgs e)
        {
            try
            {
                if (XuLiChonLua())
                {
                    _thucHien(_arrck);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Xin chọn xử lí", "Thông báo");
                }
            }
            catch (Exception ex)
            {
            }          
        }

        private void cnBoQua_Click(object sender, EventArgs e)
        {
            try
            {
                _boQua();
                this.Close();
            }
            catch (Exception ex)
            {
            }
        }

        private void cnHuy_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void ckTuDongThemMoiTatCa_CheckedChanged_1(object sender, EventArgs e)
        {
            ChonTatCa(ckTuDongThemMoiTatCa.Checked);
        }
    }
}